# we define XMLRPC::Client here so that it won't create problems
module XMLRPC
  class Client < Struct.new(:host,:path)
    def call (*args)
      args
    end
  end
end

require 'recon/site'
require 'recon/connection'
require 'test/unit'

class TC_Connection < Test::Unit::TestCase

  def setup
    @xmlrpc_site  = Site.new('xmlrpc-blog.net','path','xml-user','ilovexml')
    @invalid = Site.new('invalid','path','user','pass',0,80,:invalid)

    @xmlrpc = Connection.connect(@xmlrpc_site)
  end
  
  def test_connect
    assert Connection.connect(@xmlrpc_site)
    assert_raise(RuntimeError) { Connection.connect(@invalid) }
  end

  def test_publish
    result = @xmlrpc.publish(:some_content)
    assert_equal ['metaWeblog.newPost',1,'xml-user','ilovexml',:some_content,true],
                  result
  end

  def test_save_draft
    result = @xmlrpc.save_draft(:some_content)
    assert_equal ['metaWeblog.newPost',1,'xml-user','ilovexml',:some_content,false],
                  result
  end

end